package cn.springspace.kotlinapp.controller;

import cn.springspace.kotlinapp.model.Door
import cn.springspace.kotlinapp.repository.DoorRepository
import org.springframework.web.bind.annotation.*
import javax.validation.Valid

@RestController
@RequestMapping("/door")
class DoorController(private val doorRepository: DoorRepository) {
    @GetMapping("/listAll")
    fun getAllDoor(): List<Door> = doorRepository.findAll()

    @PostMapping("/save")
    fun createDoor(@Valid @RequestBody door: Door): Door = doorRepository.save(door)

}